import { getFormatterPrice } from '@const/filter'
// 获取月初
const getMonthfirstDay = (day = 1) => {
  let dataObj = new Date()
  dataObj.setDate(day)
  dataObj.setHours(0, 0, 0, 0)
  return dataObj
}

// 列表页tab切换
// 结算状态等待补充，目前先这样，以后改
export const accountTabsArr = [
  { lab: '待月结', val: 1, badge: { value: null } },
  { lab: '已月结', val: 2, badge: { value: null } },
  { lab: '已验票', val: 3, badge: { value: null } },
  { lab: '已撤销', val: 4, badge: { value: null } },
  { lab: '全部', val: 0, badge: { value: null } }
]

// 搜索框字段
export const accountSearchData = [
  {
    key: 'companyName',
    title: '配送商',
    type: 'input',
    attr: {
      placeholder: '请输入',
      maxlength: '99'
    }
  },
  {
    key: 'prodBigType',
    title: '产品大类',
    type: 'select',
    attr: {
      placeholder: '请选择'
    },
    options: [
      {
        label: '全部',
        value: '0'
      },
      {
        label: '高值',
        value: '1'
      },
      {
        label: '低值',
        value: '2'
      }
    ]
  },
  {
    key: 'accountDate',
    title: '核算日期',
    value: [
      getMonthfirstDay(),
      new Date()
    ],
    type: 'time',
    fieldname: ['calcBeginDate', 'calcEndDate'],
    attr: {
      style: 'width:270px !important;',
      class: 'daterange',
      type: 'daterange',
      'start-placeholder': '开始时间',
      'end-placeholder': '结束时间',
      'default-time': ['00:00:00', '23:59:59']
    }
  },
  {
    key: 'prodCode',
    title: '产品编码',
    type: 'input',
    attr: {
      placeholder: '请输入',
      maxlength: '99'
    }
  },
  {
    key: 'prodName',
    title: '产品名称',
    type: 'input',
    attr: {
      placeholder: '请输入',
      maxlength: '99'
    }
  },
  {
    key: 'manufacturer',
    title: '生产厂家',
    type: 'input',
    attr: {
      placeholder: '请输入',
      maxlength: '99'
    }
  },
  {
    key: 'prodBatch',
    title: '批号',
    type: 'input',
    attr: {
      placeholder: '请输入',
      maxlength: '99'
    }
  },
  {
    key: 'supplierName',
    title: '供应商',
    type: 'input',
    attr: {
      placeholder: '请输入',
      maxlength: '99'
    }
  },
  {
    key: 'orderItemCode',
    title: '待结算明细单号',
    type: 'input',
    attr: {
      placeholder: '请输入',
      maxlength: '99'
    }
  },
  {
    key: 'relationItemCode',
    title: '关联明细单号',
    type: 'input',
    attr: {
      placeholder: '请输入',
      maxlength: '99'
    }
  }
]

// 列表表头
export const columsData = [
  { prop: 'orderItemCode', label: '待结算明细单号', width: 180, 'show-overflow-tooltip': false },
  { prop: 'relationItemCode', label: '关联结算明细单号', width: 150, 'show-overflow-tooltip': true },
  { prop: 'prodCode', label: '产品编码', width: 100, 'show-overflow-tooltip': true },
  { prop: 'prodName', label: '产品名称', width: 150 },
  { prop: 'prodSpec', label: '规格', width: 130, 'show-overflow-tooltip': true },
  { prop: 'prodModel', label: '型号', width: 130, 'show-overflow-tooltip': true },
  { prop: 'prodMinUnit', label: '最小单位', width: 100 },
  { prop: 'prodPrice', label: '单价(元)', width: 100, formatter: row => getFormatterPrice(row.prodPrice) },
  { prop: 'prodBigType', label: '产品大类', width: 100 },
  { prop: 'productDate', label: '生产日期', width: 170 },
  { prop: 'expDate', label: '失效日期', width: 170 },
  { prop: 'prodBatch', label: '批号', width: 100, 'show-overflow-tooltip': true },
  { prop: 'serialNumber ', label: '序列号', width: 100 },
  { prop: 'udi', label: 'UDI', width: 170 },
  { prop: 'count', label: '数量', width: 80 },
  { prop: 'totalAmount', label: '金额合计(元)', width: 120, formatter: row => getFormatterPrice(row.totalAmount) },
  { prop: 'calcDate', label: '核算日期', width: 120 },
  { prop: 'prodManufacturer', label: '生产厂商', width: 170, 'show-overflow-tooltip': true },
  { prop: 'prodRegistNo', label: '注册证/备案证号', width: 170 },
  { prop: 'distributorName', label: '配送商', width: 100, 'show-overflow-tooltip': true },
  { prop: 'pssProdCode', label: '配送商产品编码', width: 150 },
  { prop: 'createDate', label: '创建时间', width: 170 },
  { prop: 'supplierName', label: '供应商', width: 170, 'show-overflow-tooltip': true },
  { prop: 'statusName', label: '结算状态', width: 100 }
]
